<?php

$num_columns	= 7;
$can_delete	= $this->auth->has_permission('School.Schoolhouse.Delete');
$can_edit		= $this->auth->has_permission('School.Schoolhouse.Edit');
$has_records	= isset($records) && is_array($records) && count($records);

if ($can_delete) {
    $num_columns++;
}
?>
<style type="text/css">
  #TB_window {top: 20%; left: 60%; margin-left: 0px; overflow: hidden;}
  .edit_tab{font-size: 12px; color: #337AB7;display: none;}
  .edit_tab i{display: inline-block;border-left: 1px solid #DCDCDC;height: 10px;margin: 0 5px;}
  .edit_tab span:hover{color: #A91500;cursor: pointer}
  .edit_tab_box{min-height: 17px;margin-top: 8px;width: 100px;}
.count_tabs .active{color: #000;}
.count_tabs i{display: inline-block;border-left: 1px solid #797979;height: 10px;margin: 0 12px;}
.count_tabs span{color: #797979; margin-left: 8px;}
.clearbtn-margin{margin-top: -2px;}
em{display: block; height: 15px;}
.column-check{width: 30px;}
</style>
<script>
        var  id_pc_arr = "";
        var  id_mobile_arr = "";
</script>
<section>
	<div class='content-header'>
	<h1>
		文章
		<a href="/<?php echo SITE_AREA . '/campaign/post/create'; ?>" class="btn btn-danger pull-right">╋   新增</a>
	</h1>
	<em></em>
    <div class="count_tabs">
    <a href="?type=1" class="itemtype <?php if(isset($search['type']) && $search['type'] == 1){echo 'active';}?>">全部</a><span>(<?php echo $totalTrashNum;?>)</span><i></i><a href="?type=2" class="itemtype <?php if(isset($search['type']) && $search['type'] == 2){echo 'active';}?>">已发布</a><span>(<?php echo $totalTrashNum;?>)</span><i></i><a href="?type=4" class="itemtype <?php if(isset($search['type']) && $search['type'] == 4){echo 'active';}?>">回收站</a><span>(<?php echo $rubishNum;?>)</span>
  </div>
  	<em></em>
	<?php echo form_open($this->uri->uri_string(), 'method="get" class="form-horizontal"'); ?>
	  	<ul class="list-inline">
	  		<li>
				<select class="form-control">
					<option>批量操作</option>
				  	<option>删除</option>
				</select>
			</li>
	  		<li><button class="btn btn-default clearbtn-margin">应用</button></li>
	  		<li>
				<select class="form-control select2" name="project">
					<option value="0">项目查询</option>
	                <?php if(isset($item_name) && !empty($item_name)) : ?>
	                <?php foreach ($item_name as $item_name) : ?>
	                	<option value="<?php echo $item_name->project_name; ?>" <?php if(isset($search['project']) && $search['project'] == $item_name->project_name){echo 'selected';}?> ><?php echo $item_name->project_name; ?></option>
	                <?php endforeach; ?>
	          		<?php endif;?>
				</select>
			</li>
<!-- 			<li>
				<select class="form-control select2" name="fenlei">
					<option value="0">所有分类</option>
	                <?php //if(isset($categories) && !empty($categories)) : ?>
	                <?php //foreach ($categories as $category) : ?>
	                	<option value="<?php //echo $category->tag_id; ?>"><?php //echo $category->tag_name; ?></option>
	                <?php //endforeach; ?>
	          		<?php //endif;?>
				</select>
			</li> -->
			<li>
			<input type="text" maxlength='100' class="form-control" id="reservation" value="<?php if(isset($search['start_date'])){echo $search['start_date'];}else{echo date("Y-m-d"); }?> -- <?php if(isset($search['end_date'])){echo $search['end_date'];}else{echo date("Y-m-d"); }?>" />
			<input type="hidden" name="start_date" id="start_date" value="" style="display:none;" />
            <input type="hidden" name="end_date" id="end_date" value="" style="display:none;" />
			</li>
			<li><button type="submit" name="save" class="btn btn-default clearbtn-margin">筛选</button></li>
	  	</ul>
  	<?php echo form_close(); ?>
</section>
	

<section class="content">
  <div class="row">
    <div class="col-xs-12">
      <div class="nav-tabs-custom">
	   <?php echo form_open($this->uri->uri_string()); ?>
       <div class="box-body">
			<table id="example2" class="table table-striped table-hover" style="table-layout:fixed;">
				<thead>
					<tr>
						<th class='column-check'><input class='check-all' type='checkbox' /></th>
						<th>标题</th>
						<th>项目</th>
						<th>编码</th>
						<th>分机号</th>
						<th>渠道</th>
	                    <th>日期</th>
	                    <th>文章类型</th>
					</tr>
				</thead>
				<?php if ($has_records) : ?>
				<tfoot>
					<?php if ($can_delete) : ?>
					<tr>
					</tr>
					<?php endif; ?>
				</tfoot>
				<?php endif; ?>
				<tbody>
					<?php
					if ($has_records) :
						foreach ($records as $record) :
					?>
					<tr class="item">
						<td class='column-check'><input type='checkbox' name='checked[]' value='<?php echo $record->id; ?>' /></td>
						<td><a href="/<?php echo SITE_AREA . '/campaign/post/edit/' . $record->id; ?>"><?php e($record->title); ?></a> <a href="<?php echo site_url('/post/' . $record->id.'/campaign?code=' . $record->building_code.'&qd=jrtt'); ?>" target="_blank"><i class="fa fa-fw fa-link"></i></a>	

                     <?php
                        if ($record->status == 3) :
                        ?>
                    <div class="edit_tab_box">
                            <div class="edit_tab">
                                                    <span>
                                                    <a href="/<?php echo SITE_AREA . '/campaign/post/changestatus/' . $record->id.'/type/2'; ?>" >还原</a>
                                                    </span><i></i>
                                                    <span>
                                                    <a href="/<?php echo SITE_AREA . '/campaign/post/changestatus/' . $record->id.'/type/3';  ?>"  style="cursor:pointer;color:#a00;" onclick="return confirm('确定要永久删除吗?');">永久删除</a>
                                                    </span>
                                                    </div>
                            </div>
                                    <?php
                                          else:
                                        ?>
                                <div class="edit_tab_box">
                                    <div class="edit_tab">
                                                <span>
                                                <a href="/<?php echo SITE_AREA . '/campaign/post/edit/' . $record->id; ?>" >编辑</a>
                                                </span><i></i>
                                                <span>
                                                <a href="/<?php echo SITE_AREA . '/campaign/post/changestatus/' . $record->id.'/type/1';  ?>"  style="cursor:pointer;color:#a00;" onclick="return confirm('确定放入垃圾箱吗?');">垃圾箱</a>
                                                </span>
                                                </div>
                                </div>
                                    <?php endif; ?>

						</td>
						<td><b><?php e(isset($record->project_name) ? $record->project_name : "无"); ?></b></td>
						<td><?php e(isset($record->building_code) ? $record->building_code : "无"); ?></td>
						<td style="word-wrap:break-word;"><?php echo (isset($record->phone) ? $record->phone : "无"); ?></td>
            			<td><?php echo (isset($record->qd) ? $record->qd : "无"); ?></td>
		              	<td><?php e($record->ctime); ?></td>
            			<td><?php e($record->type); ?></td>
	   				</tr>
					<?php
						endforeach;
					else:
					?>
					<?php endif; ?>
				</tbody>
			</table>
		</div>
		<div class="box-footer">
			<div class="pull-right">
		    	<?php echo $this->pagination->create_links(); ?>
			</div>
		</div>
	<?php
    //echo form_close();
    
   // echo $this->pagination->create_links();
    ?>
</div>
      </div>
      <!-- /.box -->
  </div>

</section>